<template>
	<view class="doclist" :style="group.list.length > 0?'background-color: #f6f6f6;':''">
		<u-navbar autoBack placeholder leftIconColor="#fff" titleStyle ="color:#fff;" bgColor="transparent" title="维普互联网医院"></u-navbar>
		<!-- 搜索 -->
		<view class="doclist_search flex-row-center font13">
			<!-- <view class="search_box flex-row-start">
				<image src="@/static/search_b.png"></image>
				<input class="input_search" :value="sech" placeholder="搜索科室,医生" maxlength="30" @input="Onsech"
					placeholder-class="placeholderClass"/>
			</view> -->
			<!-- 搜索 -->
			<u-search
				:showAction="false"
				shape="square"
				placeholder="搜索疾病、医生"
				placeholderColor="#999999"
				bgColor="#f6f6f6"
				v-model="sechi"
				@search="Onsech">
			</u-search>
		</view>
		<view class="content">
			<!-- 数据 -->
			<block v-if="sech">
				<view class="doctor-list">
					<view class="item" v-for="(item,index) in group.list" :key="index" @click="Oninquiry(item)">
						<view class="status success" v-if="item.newwork_status==1">在线</view>
						<view class="status warn" v-else-if="item.newwork_status==2">繁忙</view>
						<view class="status" v-else>离线</view>
						<view class="info u-flex">
							<image class="avatar" :src="$base.cdn(item.img,'/static/lj/common/default-doctor.png')" mode="aspectFill"></image>
							<view class="u-flex-fill">
								<view class="tit u-flex u-flex-items-end">
									<view class="name">{{item.name}}</view>
									<view class="zc">{{item.academic_title||'暂无职称'}}</view>
								</view>
								<view class="u-flex">
									<view class="address">{{item.city}}{{item.practice_organization||'暂无'}}</view>
									<view class="department">{{item.room_name||'暂无科室'}}</view>
								</view>
								<view class="num-box u-flex">
									<view class="num-item u-flex">
										<view class="label">图文问诊：</view>
										<view class="num">{{item.consultation_count}}</view>
									</view>
									<view class="num-item u-flex">
										<view class="label">视频问诊：</view>
										<view class="num">{{item.consultation_viedo_count}}</view>
									</view>
								</view>
								<view class="num-box u-flex">
									<view class="num-item u-flex">
										<view class="label">报告解读：</view>
										<view class="num">{{item.consultation_report_count}}</view>
									</view>
									<view class="num-item u-flex">
										<view class="label">好评：</view>
										<view class="num">{{parseFloat(item.score||0)>0?(parseFloat((parseFloat(item.score||0)/5*100).toFixed(2))>100?100:parseFloat((parseFloat(item.score||0)/5*100).toFixed(2)))+'%':'暂无'}}</view>
									</view>
								</view>
								<view class="con u-line-2">
									擅长：{{item.be_good_at_synopsis||'暂无'}}
								</view>
								<view class="pricebox u-flex">
									<view class="pit" v-if="item.consultation_status==1">图文：{{parseFloat(item.consultation_money||0)<=0||item.is_sign?'免费':'￥'+item.consultation_money}}</view>
									<view class="pit pit2" v-if="item.consultation_viedo_status==1">视频：{{parseFloat(item.consultation_viedo_money||0)<=0||item.is_sign?'免费':'￥'+item.consultation_viedo_money}}</view>
									<view class="pit pit3" v-if="item.consultation_report_status==1">报告解读：{{parseFloat(item.consultation_report_money||0)<=0||item.is_sign?'免费':'￥'+item.consultation_report_money}}</view>
								</view>
								<view class="u-flex u-flex-y-center u-flex-between">
									<view></view>
									<view>
										<view class="btn-wys" @click.stop="Oninquiry(item)">问医生</view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
				
				<lj-empty v-if="group.loaded&&group.list.length<=0">未搜索到相关医生</lj-empty>
				<view v-else>
					<u-loadmore
						:status="loading?'loading':(group.loaded?'nomore':'loadmore')"
						fontSize="12"
						color="#ccc"
						nomoreText="已加载全部"
						marginTop="28"
						@loadmore="Ondoctor"
					></u-loadmore>
				</view>
			</block>
			<view class="hot-tag" v-else>
				<view class="tit">热门咨询</view>
				<view class="tags">
					<view class="item" @click="Onsech('眼睛疲劳')">眼睛疲劳</view>
					<view class="item" @click="Onsech('近视/远视')">近视/远视</view>
					<view class="item" @click="Onsech('青光眼')">青光眼</view>
					<view class="item" @click="Onsech('眼底病变')">眼底病变</view>
					<view class="item" @click="Onsech('黄斑病变')">黄斑病变</view>
					<view class="item" @click="Onsech('视物模糊')">视物模糊</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				sechi:'',
				sech:'',

				group:{
					page: 1,
					limit: 10,
					list: [],
					loaded: false
				},
				loading: false,
			}
		},
		onLoad: function(options) {
			// this.sech = options.sech
			this.Ondoctor()
		},
		onReachBottom(){  //上拉触底函数
			this.Ondoctor();
		},
		methods: {
			//医生列表
			Ondoctor() {
				var that = this,group = that.group;
				if(that.loading || group.loaded) return;

				that.loading = true

				let data = {
					page: group.page,
					limit: group.limit,
					name:this.sech
				}
				this.$Http({
					url: 'doctorSearch',
					data: data,
					load: false,
					// token: false
				}).then(res => {
					if (res.code == 1) {
						var list = res.data;
						group.loaded = list.length < group.limit;
						group.page ++;
						group.list = group.list.concat(list);
					}
					that.loading = false
				}).catch(()=>{
					that.loading = false
				});
			},

			//详情页面
			Oninquiry(res) {
				console.log(res.id)
				uni.navigateTo({
					url: '/pagesA/ask/inquiry?id=' + res.id,
				})
			},
			Onsech(e){
				this.sechi = e
				this.sech = e

				this.group.list = []
				this.group.page = 1
				this.group.loaded = false
				this.loading = false

				this.Ondoctor()
			}
		}
	}
</script>

<style lang="less">
	@import url("style.less");
	page{
		height: 100%;
		background-color: #f6f6f6;
	}
</style>
